<?php
/**
 * Created by PhpStorm.
 * User: yunpeng
 * Date: 2019/1/4
 * Time: 15:45
 */

namespace App\Admin\Controllers;

use App\Models\SalesCount;
use Encore\Admin\Grid;
use Encore\Admin\Facades\Admin;
use Encore\Admin\Layout\Content;
use App\Http\Controllers\Controller;
use Encore\Admin\Controllers\ModelForm;
use Illuminate\Support\Facades\DB;


class SalesCountController   extends Controller
{
    use ModelForm;

    /**
     * Index interface.
     *
     * @return Content
     */
    public function index()
    {
        return Admin::content(function (Content $content) {
            $content->header('销售额统计');
            $content->body($this->grid());
        });
    }



    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {

        return Admin::grid(SalesCount::class, function (Grid $grid) {

            $grid->define_preg(url('admin/sales_count?cycle=date_str'), '日');

            $grid->filter(function($filter){

                // 去掉默认的id过滤器
                $filter->disableIdFilter();

            });
            $grid->cycle('周期');
            $grid->money('销售额');
            //禁用批量删除按钮
            $grid->tools(function ($tools) {
                $tools->batch(function ($batch) {
                    $batch->disableDelete();
                });
            });
            $grid->disableFilter();
            $grid->disableExport();
            $grid->disableActions();
            $grid->disableCreateButton();
        });
    }

}

